<nav class="navbar navbar-expand-lg navbar-light bg-light shadow-sm my_navbar">

    <div class="container">

        <a class="navbar-brand" href="{{route('home')}}">
            <img class="d-inline-block align-top" src="{{asset('pics/logo.png')}}" alt="logo" width="30">
            BbsChat
        </a>


        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                <li class="nav-item">
                    <a class="nav-link {{active_class(if_route('topics.index'))}}" aria-current="page" href="{{route('topics.index')}}">帖子</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(1)}}" href="{{route('categories.show',1)}}">文化</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(2)}}" href="{{route('categories.show',2)}}">体育</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(3)}}" href="{{route('categories.show',3)}}">旅行</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(4)}}" href="{{route('categories.show',4)}}">美食</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{category_navbar_active(5)}}" href="{{route('categories.show',5)}}">历史</a>
                </li>
            </ul>
            <ul class="navbar-nav ml-auto">
                @guest
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('login')}}">登录</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{route('register')}}">注册</a>
                    </li>
                @else

                    @can('manage_contents')
                        <li class="nav-item d-flex align-items-center">
                            <a class="text-decoration-none fa-solid fa-gauge px-2"
                               href="{{url(config('administrator.uri'))}}"
                               title="后台管理">
                            </a>
                        </li>
                    @endcan


                    <li class="nav-item d-flex align-items-center mx-3" title="{{Auth::user()->notification_count > 0 ?'有消息未读': '没有消息'}}">
                        <a href="{{route('notifications.index')}}"
                           class="text-{{Auth::user()->notification_count > 0 ?'danger': 'secondary'}} text-decoration-none">
                            <i class="fa-solid fa-bell"></i>
                            <span>{{Auth::user()->notification_count}}</span>
                        </a>
                    </li>



                    <li class="nav-item d-flex align-items-center">
                        <a href="{{route('topics.create')}}"
                           title="我要发帖"
                           class="fa-solid fa-plus text-primary text-decoration-none">
                        </a>
                    </li>
                    <li class="nav-item dropdown">

                        <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-expanded="false">
                            <img src="{{Auth::user()->avatar}}" alt="avatar" width="50" class="img-thumbnail">
                            {{\Illuminate\Support\Facades\Auth::user()->name}}
                        </a>

                        <div class="dropdown-menu">
                            <a class="dropdown-item text-center" href="{{route('users.show',Auth::user())}}">
                                <i class="fa-solid fa-user-tie mr-1"></i>
                                个人中心
                            </a>
                            <a class="dropdown-item text-center" href="{{route('users.edit',Auth::user())}}">
                                <i class="fa-solid fa-pen-to-square mr-1"></i>
                                编辑资料
                            </a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item text-center" href="#">
                                <form action="{{route('logout')}}" method="post" onsubmit="return confirm('您确定真的要退出?')">
                                    @csrf
                                    <button type="submit" class="btn btn-danger btn-sm">
                                        <i class="fa-solid fa-right-from-bracket"></i>
                                        退出登录
                                    </button>
                                </form>
                            </a>
                        </div>
                    </li>
                @endguest
            </ul>
        </div>
    </div>

</nav>
